package com.mht2017.common.consts;


/**
 * Author: xianghu.wang
 * Date: 2018/6/6
 * Description: 通用返回码
 */
public enum ResultCode {

    EMPTY_CODE("1", "查询结果为空"),

    SUCCESS_CODE("0", "查询成功"),

    OTHER_ERROR("-1", "其他异常"),

    PARAM_ERROR("-2", "参数错误");

    private String code;
    private String name;

    ResultCode(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ResultCode get(String code) {
        if (code != null) {
            for (ResultCode value : ResultCode.values()) {
                if (value.code.equals(code)) {
                    return value;
                }
            }
        }
        return OTHER_ERROR;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
